<?php

    header("Content-Type:text/html; charset=utf-8");
        //接收请求，处理请求，完成响应
        $username = $_POST["username"];
        $age = $_POST["age"];
        $lesson = $_POST["lesson"];
        $lifePhoto = $_POST["lifePhoto"];
        $desc = $_POST["desc"];

        //处理请求，往数据库里增加一条数据
        $con = mysqli_connect("127.0.0.1","root","","hou07");
        //判断是否已经建立链接
        if(!$con){
            printf("Can't connect to MySQL Server. Errorcode: %s ",mysqli_connect_error());
            exit;
        }

        $sql = "INSERT INTO teacher(username,age,lesson,lifePhoto,teadesc) VALUES('$username','$age','$lesson','$lifePhoto','$desc')";

        //使用mysqli_query 函数 通过$con 连接 把$sql发送到数据库
        if(!mysqli_query($con,$sql)){
            die('Error: '.mysql_error());
        }
        mysqli_query($con,$sql);

        //注册成功，我们可以让它跳转到登录页面


        mysqli_close($con);

        echo '{"status":"ok","code":200}'

?>